/*
 *  Copyright 2009 Allan Lykke Christensen.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package dk.i2m.netbeans.modules.doxia.lexer;

import org.netbeans.api.lexer.Language;
import org.netbeans.api.lexer.TokenId;

/**
 * Identifier of an APT token.
 *
 * @author Allan Lykke Christensen
 */
public class AptTokenId implements TokenId {

    private static final Language<AptTokenId> language =
            new AptLanguageHierarchy().language();
    private final String name;
    private final String primaryCategory;
    private final int id;

    /**
     * Creates a new instance of {@link AptTokenId}.
     *
     * @param token
     *          Token to base the token identifier
     */
    AptTokenId(AptToken token) {
        this(token.name(), token.category(), token.id());
    }

    /**
     * Creates a new instance of {@link AptTokenId}.
     *
     * @param name
     *          Name of the token
     * @param primaryCategory
     *          Style category of the token
     * @param id
     *          Numeric identifier of the token
     */
    AptTokenId(String name, String primaryCategory, int id) {
        this.name = name;
        this.primaryCategory = primaryCategory;
        this.id = id;
    }

    /**
     * Gets the name of the token.
     *
     * @return Name of the token
     */
    public String name() {
        return this.name;
    }

    /**
     * Gets the numeric identifier of the token.
     *
     * @return Numeric identifier of the token
     */
    public int ordinal() {
        return this.id;
    }

    /**
     * Gets the style category of the token.
     *
     * @return Style category of the token
     */
    public String primaryCategory() {
        return this.primaryCategory;
    }

    public static final Language<AptTokenId> getLanguage() {
        return language;
    }
}
